package com.itnoob.demo2;

/**
 *
 *表达式构建者类
 * @author zhoujun
 * @date 2025/3/26 21:50
 */
public class ExpressionBuilder  {

    private Expression expression; //内部表达式

    public ExpressionBuilder() {
        expression = new Original();
    }


    public ExpressionBuilder uppercase(){
         expression = new UpperCase(expression);
        return this;
    }

    public ExpressionBuilder lowercase(){
        expression = new LowerCase(expression);
        return this;
    }

    public ExpressionBuilder trim(){
        expression  = new Trim(expression);
        return this;
    }


    public ExpressionBuilder prefix(String prefix){
        expression  = new Prefix(expression,prefix);
        return this;
    }

    /**
     * 返回最终的表达式
     * @return
     */
    public Expression build(){
        return expression;
    }
}
